<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/20
 * Time: 11:14
 */

namespace App\Services\DfChannel;


class DfChannelFactory
{
    /**
     * @param $code
     * @return \App\Services\DfChannel\DfPayChannel|null
     */
    public static function getChannel($code)
    {
        if($code == null) return null;

        //include_once app_path('Service/DfChannel/DemoChannel.php');
        include_once app_path('Services/DfChannel/' . ucfirst($code) . 'Channel.php');
        $className = 'App\\Services\\DfChannel\\' . ucfirst($code) . 'Channel';
        if(!class_exists($className)) {
            return  null;
        }

        return new $className;
    }
}